using System;
using System.Collections;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace Converters
{
	public class DataGridCellDataMultiConverter : IMultiValueConverter
	{
		public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value.Length == 2 && value[0] != null && value[0] != DependencyProperty.UnsetValue && value[0] is DataGridCell && value[1] != null && value[1] != DependencyProperty.UnsetValue && value[1] is IList)
			{
				DataGridCell dataGridCell = value[0] as DataGridCell;
				IList list = value[1] as IList;
				return list[dataGridCell.Column.DisplayIndex];
			}
			return null;
		}

		public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
		{
			return null;
		}
	}
}
